package com.example.data.controller;

import com.example.data.entity.Product;
import com.example.data.service.ProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/")
public class QueryProductController {

    @Resource(name = "ProductServiceImpl")
    private ProductService productService;

    @RequestMapping("/productInfo")
    public String queryProductInfo(HttpServletRequest request, Product product,
         @RequestParam(value="pageNum", defaultValue="1")int pageNum,
         @RequestParam(value="pageSize",defaultValue="5")int pageSize){

        PageInfo<Product> pageInfo = productService.queryData(product,pageNum,pageSize);
        request.setAttribute("pageInfo",pageInfo);
        return "data/productInfo";
    }

}
